<?php
/**
 * @author 		supfire@sohu.com
 * @copyright 	
 * @version 		1.0
 * @name 		act.class.php
 * @todo 		处理动一下操作
 * @final 		2008-09-22
 */
!defined("IN_YCTOOL") && exit();
/**
 * 处理我的照片函数处理方法
 *
 */
class act
{

    /**
    * 动一下
    * @param $actid			主动作消息ID actid 1 - 12 为系统ID
    * @param $touid			接收用户数组
    * @param $fromuid			发送者 fromuid  例如：1001 或者 1002		    
    * @param $message			消息内容
    * @return bool
    * @author supfire
    * @final 2008-08-28
    */
    public static function sendAct($actid, $touid, $fromuid, $privacy)
    {
	foreach ($touid as $j => $userid)
	{
	    $Stract .= "($fromuid, $userid, 12, '$actid', ".time().", ''),";
	    $Strsys .= "($userid, $fromuid, 12, '$actid', ".time()."),";
	}
	$Stract	    = substr($Stract, 0, -1);
	$Strsys	    = substr($Strsys, 0, -1);
	$touid	    = implode(",", $touid) . ',';
	writeNewNote($touid, 12, '../../');
	if($privacy == 1)
	{
	   db::insertLotRs(DB_TABLEPRE . 'msg_action','userid, 
	    friendid, type, message, addtime, note', $Stract);
	}
	return db::insertLotRs(DB_TABLEPRE . 'msg_sys','userid, friendid,
	     type, message, addtime', $Strsys);
    }

    /**
     *
     * 添加动作信息  
     * @param string $userid, picname, $picdetail, $privacy, $password
     *    
     * @return array bool
     * @author supfire
     * @final 2008-09-18
     */
    public function addAct($act1, $act2, $newfile, $userpath)
    {
	$arr = array();
	$arr["$newfile"]["act1"] = $act1;
	$arr["$newfile"]["act2"] = $act2;
	$arr["$newfile"]["newfile"] = $newfile;
	return func::operateFile('variableact', $arr, $userpath.'act', 'php', 1);
    }

    /**
     * 修改动作信息  
     * @param string 
     * @return array bool 
     * @author supfire
     * @final 2008-09-18
     */
    public function updateAct($act1, $act2, $newfile, $userpath)
    {
	global $variableact;
	$variableact[$newfile]['act1'] = $act1;
	$variableact[$newfile]['act2'] = $act2;
	$variableact[$newfile]['newfile'] = $newfile;
	return func::operateFile('variableact', $variableact, $userpath.'act', 'php', 2);	
    }

    /**
     * 删除动作信息  
     * @param string 
     * @return array bool 
     * @author supfire
     * @final 2008-09-18
     */
    public function deleteActOne($userpath, $newfile)
    {
	global $variableact;
	if(count($variableact) > 1)
	{
	    unset($variableact[$newfile]);
	    return func::operateFile('variableact', $variableact, $userpath.'act', 'php', 2);
	}
	else
	{
	    unset($variableact[$newfile]);
	    return @unlink($userpath.'act.php');
	}	
    }

    /**
     * 修改动作信息  
     * @param string $picid, $userid, $picdetail, $privacy, $password
     * @return array bool 
     * @author supfire
     * @final 2008-09-18
     */
    public function setAct($actionid, $userid, $userpath)
    {
	$arr = array();
	$arr[$userid]["actionid"] = serialize($actionid);
	return func::operateFile('variablesetact', $arr, $userpath.'setact', 'php', 2);
    }

}
?>
